<?php
/** u2t3_BEGroup class
 * 
 * Creates a BE group
 */

require_once(t3lib_extMgm::extPath('univis2typo3').'/mod1/configuration/include/common.php');

class u2t3_BEGroup {
	var $uid_ = -1;
	var $name_ = '';
	var $nameEscaped_ = '';

	function u2t3_BEGroup() {
		// empty
	}

	function setName($n) {
		$this->name_ = $n;
		$this->nameEscaped_ = replaceUmlaute($n);
	}

	function create() { 
		if (!$this->name_) {
			echo "\t error: no groupname or sysMountId specified<br />\n";
			return -1;
		}	
		echo "\t Updating table [be_groups]...<br />\n";

		$now = time();
		$nonExclude = "pages:doktype,pages:TSconfig,pages:php_tree_stop,pages:is_siteroot,pages:storage_pid,pages:editlock,pages:hidden,pages:starttime,pages:endtime,pages:layout,pages:fe_group,pages:extendToSubpages,pages:nav_title,pages:nav_hide,pages:subtitle,pages:target,pages:alias,pages:lastUpdated,pages:newUntil,pages:cache_timeout,pages:no_cache,pages:no_search,pages:shortcut_mode,pages:content_from_pid,pages:mount_pid,pages:keywords,pages:description,pages:abstract,pages:author,pages:author_email,pages:media,pages:mount_pid_ol,pages:module,pages:fe_login_mode,pages:l18n_cfg,sys_language:hidden,sys_language:static_lang_isocode,tt_content:hidden,tt_content:starttime,tt_content:endtime,tt_content:fe_group,tt_content:sys_language_uid,tt_content:l18n_parent,tt_content:layout,tt_content:colPos,tt_content:date,tt_content:header_position,tt_content:header_link,tt_content:header_layout,tt_content:subheader,tt_content:text_align,tt_content:text_face,tt_content:text_size,tt_content:text_color,tt_content:text_properties,tt_content:imagewidth,tt_content:imageheight,tt_content:imageborder,tt_content:image_noRows,tt_content:image_link,tt_content:image_zoom,tt_content:image_effects,tt_content:image_frames,tt_content:image_compression,tt_content:imagecaption_position,tt_content:altText,tt_content:titleText,tt_content:longdescURL,tt_content:recursive,tt_content:select_key,tt_content:table_bgColor,tt_content:table_border,tt_content:table_cellspacing,tt_content:table_cellpadding,tt_content:spaceBefore,tt_content:spaceAfter,tt_content:section_frame,tt_content:splash_layout,tt_content:sectionIndex,tt_content:linkToTop,tt_content:rte_enabled,pages_language_overlay:hidden,pages_language_overlay:starttime,pages_language_overlay:endtime,pages_language_overlay:subtitle,pages_language_overlay:nav_title,pages_language_overlay:keywords,pages_language_overlay:description,pages_language_overlay:abstract,pages_language_overlay:author,pages_language_overlay:author_email,pages_language_overlay:media";
		$groupMods = "web,web_layout,web_view,file,file_list,user,user_setup";
		$pagetypes_selected = '1,2';
		$tables_selected = 'pages,tt_content,pages_language_overlay';
		$tables_modified = 'pages,tt_content,pages_language_overlay';
		$hidden = 0;

		$query = "INSERT INTO `be_groups`
				(`uid`,`pid`,`tstamp`,`title`,`non_exclude_fields`,`explicit_allowdeny`,
				`allowed_languages`,`custom_options`,`db_mountpoints`,`pagetypes_select`,
				`tables_select`,`tables_modify`,`crdate`,`cruser_id`,`groupMods`,`file_mountpoints`,
				`hidden`,`inc_access_lists`,`description`,`lockToDomain`,`deleted`,`TSconfig`,
				`subgroup`,`hide_in_lists`,`workspace_perms`
				) VALUES (
				'', 0, {$now}, '{$this->name_}', '{$nonExclude}', '',
				'', '', '', '{$pagetypes_selected}',
				'{$tables_selected}', '{$tables_modified}', '{$now}', 1, '{$groupMods}', '',
				{$hidden}, 1, '', '', 0, '',
				'', 0, 0
				);";
		performSQLQuery($query, false);
		$this->uid_ = mysql_insert_id();

		echo "\t BEGroup: ".$this->name_." added...<br />\n"; 
		return $this->uid_;
	}

	function setFileMountpoints($fileMount) {
		$query = "UPDATE `be_groups`"
			. " SET `file_mountpoints` = '{$fileMount}'"
			. " WHERE `uid` = {$this->uid_};";
		performSQLQuery($query, false);
	}

	function setDbMountpoints($dbMount) {
		$query = "UPDATE `be_groups`"
			. " SET `db_mountpoints` = '{$dbMount}'"
			. " WHERE `uid` = {$this->uid_};";
		performSQLQuery($query, false);
	}
} 
?>
